class JsonErrorMsg extends ErrorMsg {
	
	public function new( json_str:String, e:Dynamic ) {
		var str:String = "Open Flash Chart\n\n";
		str += "JSON Parse Error ["+ e.message +"]\n";
		
		// find the end of line after the error location:
		var pos: Int = json_str.indexOf( "\n", e.errorID );
		var s:String = json_str.substr(0, pos);
		var lines:Array<String> = s.split("\n");
		
		str += "Error at character " + e.errorID + ", line " + lines.length +":\n\n";

		var i : Int = 3;
		while (i > 0) {
			if( lines.length-i > -1 )
				str += Std.string(lines.length - i) +": " + lines[lines.length - i];
			i--;
		}
		super( str );
	}
}
